package com.freeLearning.boot.course.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.freeLearning.boot.course.mapper.UserCourseMapper;
import com.freeLearning.boot.course.model.entity.CourseInfo;
import com.freeLearning.boot.course.model.entity.UserCourse;
import com.freeLearning.boot.course.model.query.ByConsultantIdPageQuery;
import com.freeLearning.boot.course.service.UserCourseService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class UserCourseServiceImpl extends ServiceImpl<UserCourseMapper, UserCourse> implements UserCourseService {
    private final UserCourseMapper userCourseMapper;

    @Override
    public IPage<UserCourse> queryByConsultantPage(ByConsultantIdPageQuery query) {
        int pageNum = query.getPageNum();
        int pageSize = query.getPageSize();
        Page<CourseInfo> page = new Page<>(pageNum, pageSize);
        return this.userCourseMapper.getByConsultantPage(page, query);
    }
}
